/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BittorentPackage;

import FolderChunks.FilenameChunk;
import common.global;

/**
 *
 * @author DongVan
 */
public class ClientChunks implements Comparable<ClientChunks>{
    private FilenameChunk m_fileNameChunk;
    private int m_Port;
    private String m_ClientIP;
    public FilenameChunk getM_Chunk() {
        return m_fileNameChunk;
    }

    public void setM_Chunk(FilenameChunk m_Chunk) {
        this.m_fileNameChunk = m_Chunk;
    }

    public int getM_Port() {
        return m_Port;
    }

    public void setM_Port(int m_Port) {
        this.m_Port = m_Port;
    }

    public String getM_ClientIP() {
        return m_ClientIP;
    }

    public void setM_ClientIP(String m_ClientIP) {
        this.m_ClientIP = m_ClientIP;
    }
    
    public ClientChunks(){
        
    }
    
    public ClientChunks(FilenameChunk chunk, int port, String clientIp){
        this.m_fileNameChunk = chunk;
        this.m_Port = port;
        this.m_ClientIP = clientIp;
    }

    @Override
    public int compareTo(ClientChunks t) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        int costA = global.nodes.getCostByIpAddress(this.getM_ClientIP());
        int costB = global.nodes.getCostByIpAddress(t.getM_ClientIP());
        if(costA < costB)
            return -1;
        if(costA > costB)
            return 1;
        return 0;
    }
    
    
}
